//
//  VisitorViewController.swift
//  weibo92
//
//  Created by Apple on 15/10/17.
//  Copyright © 2015年 miao. All rights reserved.
//

import UIKit

class VisitorViewController: UITableViewController {
    
    //用户登录
    private var userLogin: Bool = false//AccountViewModel.shareAccountViewModel.userLogon
    
    //访客视图
    var visitorView: VisitorView?


    override func loadView() {
        // 根据用户登录标志，决定视图
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        
       // print(visitorView)
    }

    ///MARK: - 设置方访客视图
    private func setupVisitorView(){

        visitorView = VisitorView()
        //将根视图设置为visitorView
        view = visitorView
        
        visitorView?.delegate = self

        /// 设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
    }
}
//MARK: -设置访客视图监听方法
extension VisitorViewController:VisitorViewDelegate {
    func visitorViewDidRegister(){
        print("注册")
    }
    
    //登录
    func visitorViewDidLogin(){
        print("登录")
       
        let vc = OAuthViewController()
        
        let nav = UINavigationController(rootViewController: vc)
        
        presentViewController(nav, animated: true, completion: nil)
    }
}


